class Lodash {
    constructor() {

    }
    chunk(array, size) {
        size = Math.max(Math.floor(Number(size)), 0)
        if (!Array.isArray(array)) return []
        const newArr = [];
        for (let i = 0; i < array.length; i += size) {
            let arr = array.slice(i, (i + (size)))
            if (arr.length) {
                newArr.push(arr)
            } else {
                return newArr
            }
        }

        return newArr
    }
}

const _ = new Lodash()



console.log(_.chunk(['a', 'b', 'c', 'd'], 2));
console.log(_.chunk(['a', 'b', 'c', 'd'], 3));
console.log(_.chunk(['a', 'b', 'c', 'd'], 4));
console.log(_.chunk(['a', 'b', 'c', 'd'], 1));
